<?php
$this->setLayout('template'.DS.'empty.phtml');

$this->startBlock();
?>
<script language="javascript" type="text/javascript">
var currentPage = 1;
var pageCount = <?php echo $this->pageCount ?>;
var url = '<?php echo $this->getUrl(array('id'=>$this->model->getId()), 'generate-picture') ?>';

function generatePicture(){
    $('<p>第' + currentPage + '页处理中</p>').appendTo('body');
    $.ajax({
        url:url + '/page/' + currentPage,
        method:'GET',
        success:function(data, textStatus, request){
            $('<p>第' + currentPage + '处理完成</p>').appendTo('body');
            currentPage++;
            if(currentPage <= pageCount){
                generatePicture();
            }else{
                $('<p><?php echo Kd_Localize_Helper::__f('media.message.generate5', $this->model->getTitle())?></p>').appendTo('body');
                location.href = '<?php echo $this->getUrl(array('id'=>$this->model->getId()), 'compress') ?>';
            }
        }
    });
}
$(function(){
    generatePicture();
});
</script>
<p><?php echo Kd_Localize_Helper::__f('media.message.generate1', $this->model->getTitle())?></p>
<p><?php echo Kd_Localize_Helper::__f('media.message.generate2', $this->pageCount)?></p>
<?php
$this->endBlock();